//
//  LS_DestinationViewController.m
//  breadPro
//
//  Created by 刘文超 on 2019/7/4.
//  Copyright © 2019 刘文超. All rights reserved.
//

#import "LS_DestinationViewController.h"
#import "LS_DestinatViewModel.h"
#import "LS_TableViewBindingHelper.h"
#import "LS_TableView.h"
#import "LS_DestinationView.h"
@interface LS_DestinationViewController ()
@property(nonatomic,strong)LS_DestinatViewModel *viewModel;

/**
 bind tableview
 */
@property(nonatomic,strong)LS_TableViewBindingHelper *destinationHelper;

/**
 视频banner
 */
@property(nonatomic,strong)UIView *headerView;

/**
 tableview
 */
@property(nonatomic,strong)LS_TableView *destinaTableView;

/**
 视频banner
 */
@property(nonatomic,strong)LS_DestinationView *destinaView;

@end

@implementation LS_DestinationViewController
-(instancetype)initWithModel:(LS_DestinatViewModel *)viewModel
{
    if (self =[super init]) {
        self.viewModel = viewModel;
    }return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"设计";
    
    [self bindViewModel];
}
-(void)bindViewModel
{
    //请求数据
    self.viewModel.MyVC = self;
    [self.viewModel.feedDataCommand execute:@1];
    
  self.destinationHelper = [LS_TableViewBindingHelper bindingHelperForTableView:self.destinaTableView sourceSignal:RACObserve(self.viewModel, feedData) selectCommand:self.viewModel.feedDetailCommand templateCell:@"LS_DestinFeedTableViewCell" withViewModel:self.viewModel];
    
    self.destinaView.modelSignal = RACObserve(self.viewModel, videoData);
    
}
-(LS_DestinationView *)destinaView
{
    return LS_LAZY(_destinaView, ({
        LS_DestinationView *destinView =[[LS_DestinationView alloc]initWithFrame:CGRectMake(0, 15, ScreenWidth, 200)];
        destinView.autoscrollTimeInterval = 0.5;
        destinView.cornerRadius = 10;
        [self.view addSubview:destinView];
        destinView;
    }));
}
-(LS_TableView *)destinaTableView
{
    return LS_LAZY(_destinaTableView, ({
        LS_TableView *destinaTableView = [[LS_TableView alloc]initWithFrame:self.view.bounds];
        [self.view addSubview:destinaTableView];
        destinaTableView.tableHeaderView = self.headerView;
        destinaTableView.rowHeight = 410;
        destinaTableView;
    }));
}
-(UIView *)headerView
{
    return LS_LAZY(_headerView, ({
        UIView *headView =[[UIView alloc]init];
        headView.frame = CGRectMake(0, 0, ScreenWidth, 230);
        [headView addSubview:self.destinaView];
        headView;
    }));
}
@end
